package com.igeek.javase.ch02;

import java.util.Scanner;

/*
 *@author wangpeng
 *2023/7/11 15:27
 *@description IfTest1
 */
public class IfTest1 {
    public static void main(String[] args) {
        System.out.println("请输入第一个数字：");
        int num1 = new Scanner(System.in).nextInt();

        System.out.println("请输入第一个数字：");
        int num2 = new Scanner(System.in).nextInt();

        System.out.println("请输入运算符：");
        String s= new Scanner(System.in).next();
        int sum =0;
        if ("+".equals(s)){
            sum=num1+num2;
        }else if("-".equals(s)){
            sum=num1-num2;
        }else if("*".equals(s)){
            sum=num1*num2;
        }else if("/".equals(s)){
            if(num1==0&&num2!=0){
                sum=num1/num2;
            }else if(num1!=0 && num2==0){
                System.out.println("除数不能为0,请检查输入！");
                return;
            }else{
                System.out.println("除数不能为0,请检查输入！");
                return;
            }
        }
        System.out.println(num1 + s + num2 +"="+sum);
    }
}


